<!DOCTYPE html>
<!--
/*******************************************************************************
#      ____               __          __  _      _____ _       _               #
#     / __ \              \ \        / / | |    / ____| |     | |              #
#    | |  | |_ __   ___ _ __ \  /\  / /__| |__ | |  __| | ___ | |__   ___      #
#    | |  | | '_ \ / _ \ '_ \ \/  \/ / _ \ '_ \| | |_ | |/ _ \| '_ \ / _ \     #
#    | |__| | |_) |  __/ | | \  /\  /  __/ |_) | |__| | | (_) | |_) |  __/     #
#     \____/| .__/ \___|_| |_|\/  \/ \___|_.__/ \_____|_|\___/|_.__/ \___|     #
#           | |                                                                #
#           |_|                 _____ _____  _  __                             #
#                              / ____|  __ \| |/ /                             #
#                             | (___ | |  | | ' /                              #
#                              \___ \| |  | |  <                               #
#                              ____) | |__| | . \                              #
#                             |_____/|_____/|_|\_\                             #
#                                                                              #
#                              (c) 2010-2011 by                                #
#           University of Applied Sciences Northwestern Switzerland            #
#                     Institute of Geomatics Engineering                       #
#                           martin.christen@fhnw.ch                            #
********************************************************************************
*     Licensed under MIT License. Read the file LICENSE for more information   *
*******************************************************************************/

         TUTORIAL 5.3: Change Size, Position and Orientation of a 3D-Object
                      
*******************************************************************************/
-->
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="../../../external/closure-library/closure/goog/base.js"></script>
<script type="text/javascript" src="../../../compiled/deps.js"></script>
<script type="text/javascript">goog.require('owg.OpenWebGlobe');</script>

<button onclick="doubleSize();">Size ++</button>
<button onclick="halfSize();">Size --</button>
<button onclick="incyaw();">Yaw ++</button>
<button onclick="incpitch();">Pitch ++</button>
<button onclick="incroll();">Roll ++</button>
<button onclick="inclat();">Lat ++</button>
<button onclick="inclng();">Lng ++</button>


<script type="text/javascript">

var geometrylayer = null;
var hidden = false;
var geometry1 = -1;

//------------------------------------------------------------------------------
function main()
{
   // (0) Set location of Artwork directory. Because of CORS this can't be local
   // if you want to open this using file://...
   ogSetArtworkDirectory("http://www.openwebglobe.org/art/");
   
   // (1) create an OpenWebGlobe context using canvas
   // first parameter is canvas-id and second is "fullscreen"
   var ctx = ogCreateContextFromCanvas("canvas", true);
   
   // (2) Create a virtual globe
   var globe = ogCreateGlobe(ctx);
   
   // (3) Add an image and an elevation layer
   var imgBlueMarble500 = 
   {
      url     : ["http://www.openwebglobe.org/data/img"],
      layer   : "World500",
      service : "i3d"
   };
   
   var imgLandsat_CH = 
   {
      url     : ["http://www.openwebglobe.org/data/img"],
      layer   : "LandsatCH",
      /*transparency : 0.5,*/
      service : "i3d"
   };
   
   var elvSRTM_CH = 
   {
      url     : ["http://www.openwebglobe.org/data/elv"],
      layer   : "SRTM",
      service : "i3d"
   };
         
   ogAddImageLayer(globe, imgBlueMarble500);
   ogAddImageLayer(globe, imgLandsat_CH);
   ogAddElevationLayer(globe, elvSRTM_CH);
   
   // (6) Set the background color
   ogSetBackgroundColor(ctx, 0.2,0.2,0.7,1);
   
   // (7) 3D Model
   // first, we need to retrieve the scene:
   var scene = ogGetScene(ctx);
   
   //then, we need to retrieve the world
   var world = ogGetWorld(scene);
	
   //create a geometry layer
   geometrylayer = ogCreateGeometryLayer(world,"buildings");


   //create the first 3d model                   
   geometry1 = ogLoadGeometryAsync(geometrylayer,"torus.json");
   ogFlyToLookAtPosition(scene, 7.438637,46.951081,3400, 1000,30,-45,0);

}
var lng =  7.438637;
var lat = 46.951081;
var elv = 3400;

function doubleSize()
{
   //double the model size
   ogSetGeometryScale(geometry1,2,2,2);
}

function halfSize()
{
   //half the model size
   ogSetGeometryScale(geometry1,0.5,0.5,0.5);
}

function incyaw()
{
   //turn by 1 degree
   ogSetGeometryOrientation(geometry1,1,0,0);

}


function incpitch()
{
   //turn by 1 degree
   ogSetGeometryOrientation(geometry1,0,1,0);

}


function incroll()
{
    //turn by 1 degree
    ogSetGeometryOrientation(geometry1,0,0,1);

}

function inclat()
{

    lat = lat+0.001;
    ogSetGeometryPositionWGS84(geometry1,lng,lat,elv);

}

function inclng()
{
    lng = lng+0.001;
    ogSetGeometryPositionWGS84(geometry1,lng,lat,elv);

}

</script>

</head>
<body onload="main()" style="padding:0px; margin:0px; overflow:hidden;">
   <div style="text-align: center">
   <canvas id="canvas"></canvas>          
   </div>
</body>
</html>
